package com.webdemo10.action;

import org.apache.struts2.convention.annotation.Action;
import org.apache.struts2.convention.annotation.Namespace;
import org.apache.struts2.convention.annotation.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;

import com.opensymphony.xwork2.ActionSupport;
import com.webdemo10.pojo.User;
import com.webdemo10.service.UserService;

@Controller
@Namespace("/ssh/jsp")
@Action(value = "addUser", results = { 
		@Result(location = "queryUser", type = "redirectAction") })
public class AddUser extends ActionSupport {
	private static final long serialVersionUID = 1L;
	@Autowired
	private UserService userService;
	private User user;
	public User getUser() {
		return user;
	}
	public void setUser(User user) {
		this.user = user;
	}
	public AddUser() {
		System.out.println("action");
	}
	@Override
	public String execute() throws Exception {
		System.out.println(user.getName());
		userService.addUser(user);
		return SUCCESS;
	}
}
